package StudyCode.summary.myfile;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ByteArrayHexidecimalString {
	public static void main(String[] argv) {
		byte[] buf = new byte[]{0x12, 0x23};
		System.out.println("byte 数组转为16进制字符串: " + hexEncode(buf));
	}

	private static String hexEncode(byte[] array) {
		StringBuilder sb = new StringBuilder();

		for (byte anArray : array) {
			sb.append(Integer.toHexString((anArray & 0xFF) | 0x100).substring(1, 3));
		}

		return sb.toString();
	}
}
